package com.itheima.d7_IO.Change;

import java.io.*;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

public class Test2 {
    public static void main(String[] args) {
        //经典代码，开发常用按行读
        // 1. 将低级的字符流包装成高级流  E:\FileResource\Test2.txt 这是个GBK的文件
        try (
                InputStream fileInputStream = new FileInputStream("E:\\FileResource\\Test2.txt");
                InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream,"GBK");
                //   Reader fileReader = new FileReader("E:\\FileResource\\Test2.txt");
                BufferedReader bufferedReader = new BufferedReader(inputStreamReader);//这个和FileReader一样

        ) {
            String line; //读了多少个
            while((line = bufferedReader.readLine()) != null) {
                System.out.println(line);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
